/**
 * @file doatexit.c
 * @author liangwenhao (1943080020@qq.com)
 * @brief 
 * @version 0.1
 * @date 2021-07-21
 * 
 * @copyright Copyright (c) 2021
 * 
 * @authorGitee  https://gitee.com/liangwenhao
 * @authorGithub https://github.com/WHaoL
 * @authorBlogs https://blog.csdn.net/liangwenhao1108
 *  
 * @Code Description: 测试atexit()函数 P161-162
 *  
 */

#include "apue.h"

static void my_exit1(void);
static void my_exit2(void);

int 
main(void)
{
    if(atexit(my_exit2) != 0)
        err_sys("can't register my_exit2");

    if(atexit(my_exit1) != 0)
        err_sys("can't register my_exit1");
    if(atexit(my_exit1) != 0)
        err_sys("can't register my_exit1");

    printf("main is done\n");
    return(0);
}

static void my_exit1(void)
{
    printf("firt exit handler\n");
}
static void my_exit2(void)
{
    printf("second exit handler\n");
}

//  make clean && make 